<?php

/**
 * Menashop
 *
 * LICENSE
 *
 * This source file is subject to the license that is bundled
 * with this project in the file LICENSE.txt
 *
 * @category   Zend
 * @package    Storefront_View_Helper
 * @subpackage Breadcrumb
 * @copyright  Copyright (c) 2011 Menashop UA Inc. (http://www.menashop.com.ua)
 * @license    LICENSE.txt
 * @version    1.0.0
 * @since      File available since Release 1.0.0
 */

/**
 * The helper for breadcrumb
 * 
 * @category   Zend
 * @package    Storefront_View_Helper
 * @subpackage Breadcrumb
 * @copyright  Copyright (c) 2011 Menashop UA Inc. (http://www.menashop.com.ua)
 * @license    LICENSE.txt
 */
class Storefront_View_Helper_Breadcrumb extends Zend_View_Helper_Abstract
{

    /**
     * Get HTML for the breadrumb
     */
    public function Breadcrumb($product = null)
    {
        $language = $this->view->language;
        if ($this->view->breadcrumb) {
            $bread = $this->view->breadcrumb;
            $crumbs = array();
            $bread = array_reverse($bread);

            $crumbs[] = '<a href="/' . $language . '/">' . $this->view->translate('Start') . '</a>';
            foreach ($bread as $category) {
//                $href = $this->view->url(array(
//                    'categoryIdent' => $category->ident,
//                    ), 
//                    'catalog_category'
//                );
                $crumbs[] = '<a href="/' . $language . '/catalog/' . $category->id . '">' . $this->view->escape($category->name) . '</a>';
            }

            if (null !== $product) {
                $crumbs[] = '<a href="/' . $language . '/product/' . $product->id . '">' . $this->view->escape($product->manufacturer_name) . '&nbsp;' . $this->view->escape($product->name) . '</a>';
            }

            return join(' &raquo; ', $crumbs);
        }
    }

}

